//
//  JGBaseOrderController.m
//  JGRider
//
//  Created by 单启志 on 2018/1/29.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGBaseOrderController.h"
#import "JGBaseOrderHeadView.h"
#import "JGBaseOrderCell.h"
#import "LMJUMengHelper.h"

@interface JGBaseOrderController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;

@end

@implementation JGBaseOrderController
static NSString *cellId=@"baseOrderCell";
- (void)viewDidLoad {
    [super viewDidLoad];

    [self configSubviews];
}

-(void)configSubviews{
    //self.datas=[JGOrderModel models];

    self.title=self.type==OrderTypeRanking?@"接单排行":@"好评排行";

    [self.view addSubview:self.tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

#pragma mark - tableview delegate

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    JGBaseOrderHeadView *headView=[[[NSBundle mainBundle]loadNibNamed:@"JGBaseOrderHeadView" owner:nil options:nil]lastObject];
    headView.orderType=self.type;
    return headView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return AdaptedHeight(147);
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [[UIView alloc]init];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
    //return self.datas.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return AdaptedHeight(94);
    //    return [tableView fd_heightForCellWithIdentifier:cellId configuration:^(JGRankingOrderCell *cell) {
    //        cell.model=self.datas[indexPath.row];
    //    }];
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    JGBaseOrderCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
    //cell.model=self.datas[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


}

#pragma mark - override
-(UIImage *)lmjNavigationBarRightButtonImage:(UIButton *)rightButton navigationBar:(LMJNavigationBar *)navigationBar{

    return [UIImage imageNamed:@"ranking_icon_share"];
}

-(void)rightButtonEvent:(UIButton *)sender navigationBar:(LMJNavigationBar *)navigationBar{
    NSLog(@"分享排行");

    [LMJUMengHelper shareTitle:@"你是我心中最美的云彩" subTitle:@"猥琐男" thumbImage:@"https://avatars2.githubusercontent.com/u/18454795?s=400&u=c8a7cc691e5c3611e9fb49dcf9c83843dd9141a2&v=4" shareURL:@"www.baidu.com"];
}

#pragma mark - getter setter
-(UITableView *)tableView{

    if (!_tableView) {

        _tableView =[[UITableView alloc]initWithFrame:CGRectMake(0,self.lmj_navgationBar.height, JGScreenW, JGScreenH-self.lmj_navgationBar.height) style:UITableViewStyleGrouped];

        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([JGBaseOrderCell class]) bundle:nil] forCellReuseIdentifier:cellId];

        _tableView.showsVerticalScrollIndicator=NO; _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        _tableView.delegate=self;
        _tableView.dataSource=self;
    }

    return _tableView;

}




@end
